package com.zy.service;

import com.spring.BeanPostProcessor;
import com.spring.annotation.Component;

@Component("zyBeanPostProcessor")
public class ZyBeanPostProcessor implements BeanPostProcessor {

    // 针对所有的Bean的后置处理器
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        // 如果是针对某写bean，需要添加 beanName 判断
        if (beanName.equalsIgnoreCase("userService")) {
            // TODO
            System.out.println("postProcessAfterInitialization");

            // AOP 需要返回代理对象，这里新建一个代理对象，然后返回回去
        }
        return bean;
    }
}
